package com.fenyin.samples.study.jdk.annotation;  

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
  
public class MongoPo {
	
	@MongoClumn(name="a")
	private int id;
	
	@MongoClumn(name="b")
	private String desc;
	
	public MongoPo(int id,String desc){
		this.id = id;
		this.desc = desc;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	public static void main(String[] args){
		MongoPo mongoPo = new MongoPo(10,"第一条数据");
		
		Field[] fields = mongoPo.getClass().getDeclaredFields();
		for(Field field : fields){
			boolean hasAnnotation = field.isAnnotationPresent(MongoClumn.class);
			if(hasAnnotation){
				MongoClumn mongoClumn = field.getAnnotation(MongoClumn.class);
				System.out.println(mongoClumn.name());
			}
		}
		
		Annotation annotation =  mongoPo.getClass().getAnnotation(MongoClumn.class);
		
		
	}
}
